
import {getTimestamp,filterTimeHMS} from './time'

export class Collection{
	constructor(props){
		this.that = props.that
		this.realName = props.realName;
		this.mobile = props.mobile;
		this.overDaysStart = props.overDaysStart;
		this.overDaysEnd = props.overDaysEnd;
		this.entryTime = props.entryTime;
		this.lastEntryTime = props.lastEntryTime;
		this.time = props.time;
		this.status = props.status;
		this.size = props.size;
		this.page = props.page;
	}
	getState(){
		let x = {}

		// 姓名
		if(this.realName){
			x.realName = this.realName
		}
		//手机号
        if(this.mobile){
          if(!/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.mobile)){
          	// this.that.showMsg("请输入正确的手机号",'error')
            return {code:'0',message:'请输入正确的手机号'}
          }else{
            x.mobile = this.mobile
          }
        }
        //起始逾期天数
        if(this.overDaysStart){
          if(!/^[0-9]*$/.test(this.overDaysStart)){
            //  this.that.showMsg("请输入正确的起始金额",'error')
            return {code:'0',message:'请输入正确的起始逾期天数'}
          }else{
            x.overDaysStart = this.overDaysStart
          }
        }
        if(this.overDaysEnd){
          if(!/^[0-9]*$/.test(this.overDaysEnd)){
            // this.that.showMsg("请输入正确的结束金额",'error')
            return {code:'0',message:'请输入正确的结束逾期天数'}
          }else{
            x.overDaysEnd = this.overDaysEnd
          }
        }
        if(this.loanMoneyBegin&&this.overDaysEnd){
          if(Number(this.loanMoneyBegin)>=Number(this.overDaysEnd)){
            // this.that.showMsg("起始金额不得大于结束金额",'error')
            return {code:'0',message:'起始金额不得大于结束金额'}
          }
        }
        // 入催时间开始
        if(this.entryTime){
          x.entryTimeStart = this.entryTime ? getTimestamp(this.entryTime[0]) : undefined;
          x.entryTimeEnd = this.entryTime ? getTimestamp(this.entryTime[1])+ 86399999 : undefined;
        }
        //上次入催时间
        if(this.lastEntryTime){
          x.lastEntryTimeStart = this.lastEntryTime ? getTimestamp(this.lastEntryTime[0]) : undefined;
          x.lastEntryTimeEnd = this.lastEntryTime ? getTimestamp(this.lastEntryTime[1])+ 86399999 : undefined;
        }
        //催收状态
        if(this.status){
        	x.status = this.status
        }



    //催收记录 
        // 入催日期
        if(this.time){
          	x.startTime = this.time ? getTimestamp(this.time[0]) : undefined;
          	x.endTime = this.time ? getTimestamp(this.time[1])+ 86399999 : undefined;
        }

		x.size = this.size
		x.page = this.page
		return x
	}

};










export  default Collection